
/* Generated by Interface Builder */

#import "SphereControl.h"
#import "SphereDrawerObject.h"
#import <appkit/appkit.h>

@implementation SphereControl


- init
{
	[super init];
	radius=100;
	theta=0;
	phi=0;
	lat=10;
	longi=10;
	hideFlag=FALSE;
	shadeFlag=FALSE;
	autoDraw=FALSE;
	return self;
}


- getRadiusSlider:sender
{
	[self writeRadius:[sender intValue]];
	[radiusTextDisplayPtr setIntValue:[self readRadius]];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- getThetaSlider:sender
{
	[self writeTheta:[sender intValue]];
	[thetaTextDisplayPtr setIntValue:[self readTheta]];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}
- getPhiSlider:sender
{
	[self writePhi:[sender intValue]];
	[phiTextDisplayPtr setIntValue: [self readPhi]];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- getLatSlider:sender
{
	[self writeLat:[sender intValue]];
	[latTextDisplayPtr setIntValue: [self readLat]];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- getLongSlider:sender
{
	[self writeLong:[sender intValue]];
	[longTextDisplayPtr setIntValue: [self readLong]];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- (int) readRadius
{
	return radius;
}

- (int) readTheta
{
	return theta;
}

- (int) readPhi
{
	return phi;
}

- (int) readLat
{
	return lat;
}

- (int) readLong
{
	return longi;
}

- (BOOL) readShadeFlag
{
	return shadeFlag;
}

- (BOOL) readHideFlag
{
	return hideFlag;
}

- (BOOL) readAutoDraw
{
	return autoDraw;
}

- writeRadius:(int) val;
{
	radius=val;
	return self;
}

- writeTheta:(int) val;
{
	theta=val;
	return self;
}

- writePhi:(int) val;
{
	phi=val;
	return self;
}

- writeLat:(int) val;
{
	lat=val;
	return self;
}

- writeLong:(int) val;
{
	longi=val;
	return self;
}

- writeHideFlag:(BOOL) val
{
	hideFlag=val;
	return self;
}

- writeShadeFlag:(BOOL) val
{
	shadeFlag=val;
	return self;
}

- writeAutoDraw:(BOOL) val
{
	autoDraw=val;
	return self;
}

- messageSphereDrawer: sender
{
	[sphereViewPtr display];
	return self;
}

- clickHideBox: sender
{
	if (hideFlag==FALSE) [self writeHideFlag:TRUE];
	else
	{
		[self writeHideFlag:FALSE];
		if (shadeFlag==TRUE)
		{
			[self writeShadeFlag: FALSE];
			[shadeBoxPtr setState:FALSE];
		}
	}
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- clickShadeBox: sender
{
	if (shadeFlag==FALSE)
	{
		[self writeShadeFlag:TRUE];
		if (hideFlag==FALSE)
		{
			[self writeHideFlag:TRUE];
			[hideBoxPtr setState:TRUE];
		}
	}
	else [self writeShadeFlag:FALSE];
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- autoRender: sender
{
	if (autoDraw==FALSE)
	{
		autoDraw=TRUE;
		[autoRenderPtr setTitleNoCopy: "Deactivate Auto-render"];
	}
	else
	{
		autoDraw=FALSE;
		[autoRenderPtr setTitleNoCopy: "Activate Auto-render"];
	}
	if (autoDraw==TRUE) [self messageSphereDrawer: self];
	return self;
}

- loadInfoNib:sender
{
	if (infoPanel == nil)
	{
		[NXApp loadNibSection:"InfoPanel.nib" owner:self];
	}
	[infoPanel makeKeyAndOrderFront:self];	
	return self;
}

- loadHelpNib:sender
{

	if (helpPanel == nil)
	{
		[NXApp loadNibSection:"HelpPanel.nib" owner:self];
	}
	[helpPanel makeKeyAndOrderFront:self];	

	return self;
}

@end

